package com.margo.project.web.cors.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.margo.project.web.cors.model.MargoCorsVO;

/**
 * 	https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Access_control_CORS
 * 	跨域请求,简单请求
 * Content-Type 的值仅限于下列三者之一：
 * text/plain
 * multipart/form-data
 * application/x-www-form-urlencoded
 * @author fxb208
 *
 */
@Controller
@RequestMapping("/cors")
public class MargoCorsController {
	
	Logger logger=LoggerFactory.getLogger(this.getClass());

	@ResponseBody
	@RequestMapping("/form")
	public String form(MargoCorsVO margoCorsVO) {
		return "ok";
	}
	
	@ResponseBody
	@RequestMapping("/json")
	public String json(@RequestBody MargoCorsVO margoCorsVO) {
		return "ok";
	}
	
	@ResponseBody
	@RequestMapping("/form2")
	public String form2(HttpServletRequest request,MargoCorsVO margoCorsVO) {
		logger.info("token:"+request.getHeader("token")); 
		return "ok";
	}
	
	@ResponseBody
	@RequestMapping("/json2")
	public String json2(HttpServletRequest request,@RequestBody MargoCorsVO margoCorsVO) {
		logger.info("token:"+request.getHeader("token")); 
		return "ok";
	}
}
